
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

namespace ScrewTurn.Wiki {

	public partial class Category : BasePage {

		protected void Page_Load(object sender, EventArgs e) {
			Page.Title = Resources.Messages.CategoryTitle + " - " + Settings.WikiTitle;

			PrintCat();
		}

		public void PrintCat() {
			StringBuilder sb = new StringBuilder();
			sb.Append("<ul>");
			sb.Append("<li>" + @"<a href=""AllPages.aspx?Cat=-"">");
			sb.Append(Resources.Messages.UncategorizedPages);
			sb.Append("</a> (");
			sb.Append(Pages.Instance.GetUncategorizedPages().Length.ToString());
			sb.Append(")");
			sb.Append(@" - <small><a href=""RSS.aspx?Category=-"" title=""");
			sb.Append(Resources.Messages.RssForThisCategory);
			sb.Append(@""">RSS</a></small>");
			sb.Append("</li></ul><br />");

			sb.Append("<ul>");
			for(int i = 0; i < Pages.Instance.AllCategories.Count; i++) {
				if(Pages.Instance.AllCategories[i].Pages.Length > 0) {
					sb.Append(@"<li>");
					sb.Append(@"<a href=""AllPages.aspx?Cat=");
					sb.Append(Tools.UrlEncode(Pages.Instance.AllCategories[i].Name));
					sb.Append(@""">");
					sb.Append(Pages.Instance.AllCategories[i].Name);
					sb.Append("</a> (");
					sb.Append(Pages.Instance.AllCategories[i].Pages.Length.ToString());
					sb.Append(")");
					sb.Append(@" - <small><a href=""RSS.aspx?Category=");
					sb.Append(Tools.UrlEncode(Pages.Instance.AllCategories[i].Name));
					sb.Append(@""" title=""");
					sb.Append(Resources.Messages.RssForThisCategory);
					sb.Append(@""">RSS</a></small>");
					sb.Append("</li>");
				}
				else {
					sb.Append(@"<li><i>");
					sb.Append(Pages.Instance.AllCategories[i].Name);
					sb.Append("</i></li>");
				}
			}
			sb.Append("</ul>");
			lblCatList.Text = sb.ToString();
		}

	}

}
